#include <stddef.h>
#include <stdio.h>
#include <getopt.h>
#include <stdlib.h>
#include <../include/server.h>

void server_getopt_long(int argc, char **argv)
{
    int                   opt = -1;
    struct   option       opt_long[] =
    {
        {"listen_port", required_argument, 0, 'p'},
        {"help", no_argument, 0, 'h'},
        {0, 0, 0, 0}
    };

    while( (opt = getopt_long(argc, argv, "p:h", opt_long, NULL)) != -1 )
    {

        switch(opt)
        {
            case 'p':
                listen_port = atoi(optarg);
                break;
            case 'h':
                printf_help(argv[0]);
                exit(0);
            default:
                break;
        }
    }
    if(!listen_port)
    {

        printf_help(argv[0]);
        exit(-1);

    }
    printf("listen_port:%d\n", listen_port);

}

